var mysql = require('mysql')
        , config = require('.././config');

var db;

/**
 *  Initializes this script's db (database) object which servers as the connection
 * of this script to the MySQL database
 * @returns {Database} db the database object where the user may perform queries
 */
exports.connectMySQL = function() {
    db = mysql.createConnection(config);
    if (db) {
        return db;
    }
};

/**
 *  Disconnects this script to the MySQL database. ALWAYS call this method after
 * using this script.
 * @returns {undefined}
 */
exports.disconnectMySQL = function() {
    if (db) {
        db.end();                
    }
};